using System;
using System.Collections.Generic;
using System.Text;

using System.Web;
using System.Web.SessionState;
using Pampa.CRUD.Exceptions;
using Pampa.Grid.UI.CustomControls;

namespace Pampa.Grid.Utils
{
    public static class Session
    {
        public static void SaveList(CustomGrid grid)
        {
            HttpContext.Current.Session["grid_" + grid.ID] = grid;
        }

        public static CustomGrid GetList(string ID)
        {
            var grid = (CustomGrid)HttpContext.Current.Session["grid_" + ID];

            if(grid == null)
            {
                throw  new SessionExpiratedException("Session Expired");
            }
            else
            {
                return grid;
            }
        }
    }
}
